package com.gitee.hljdrl.utils.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class ActivityUtil {

    public static boolean isDestroyed(Activity _activity) {
        if (_activity == null || _activity.isDestroyed() || _activity.isFinishing()) {
            return true;
        }
        return false;
    }

    public static void startActivity(Activity activity, Class<?> cls) {
        startActivity(activity, cls, null);
    }

    public static void startActivity(Activity activity, Class<?> cls, Bundle bundle) {
        Intent intent = new Intent(activity, cls);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        activity.startActivity(intent);
    }

    public static void startActivityForResult(Activity activity, Class<?> cls, int requestCode) {
        startActivityForResult(activity, cls, requestCode, null);
    }

    public static void startActivityForResult(Activity activity, Class<?> cls, int requestCode, Bundle bundle) {
        Intent intent = new Intent(activity, cls);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        activity.startActivityForResult(intent, requestCode);
    }
}
